package cn.controller;

import cn.pojo.Order;
import cn.pojo.User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * pojo数据类型绑定
 */
@RestController
@RequestMapping("pojo")
public class PojoController {

    @PostMapping("register")
    public String register(User user) {
        return user.toString();
    }

    /**
     * postman以post方式访问
     * localhost:8080/pojo/register
     * 并在params中填写id、username、password参数
     * <p>
     * postman中返回值 "User(id=10001, username=zhangsan, password=123456)"
     */

    // 包装pojo测试
    @PostMapping("addOrder")
    public String addOrder(Order order) {
        return order.toString();
    }
    /**
     * postman以post方式访问
     * localhost:8080/pojo/addOrder
     * 注意填写包装pojo时,应该为user.id、user.username、user.password
     *
     * postman中返回值 "Order(orderId=11111, user=User(id=10001, username=jack, password=123456))"
     */
}
